package com.theeviljames.graph;

import java.util.Enumeration;
import java.util.Hashtable;

public class Graph {
	
	private Hashtable<String, Hashtable<String, Double>> graph;
	
	public Graph() {
		graph = new Hashtable<String, Hashtable<String,Double>>();
	}
	
	public void addVertex(String name, Hashtable<String, Double> edges){
		graph.put(name, edges);
	}
	
	public Hashtable<String, Double> getAdjacent(String name){
		return graph.get(name);
	}
	
	public Enumeration<String> getVertices(){
		return graph.keys();
	}
	
	public void initDijkstra(){
		Hashtable<String, Double> s = new Hashtable<String, Double>();
		s.put("t", 10.0);
		s.put("y", 5.0);
		addVertex("s",s);
		
		Hashtable<String, Double> t = new Hashtable<String, Double>();
		t.put("x", 1.0);
		t.put("y", 2.0);
		addVertex("t",t);
		
		Hashtable<String, Double> x = new Hashtable<String, Double>();
		x.put("z",4.0);
		addVertex("x",x);
		
		Hashtable<String, Double> y = new Hashtable<String, Double>();
		y.put("t", 3.0);
		y.put("x", 4.0);
		y.put("z", 2.0);
		addVertex("y",y);
		
		Hashtable<String, Double> z = new Hashtable<String, Double>();
		z.put("s",7.0);
		z.put("x",6.0);
		addVertex("z",z);		
	}
	
	public void initKruskal(){
		Hashtable<String, Double> a = new Hashtable<String, Double>();
		a.put("b", 4.0);
		a.put("h", 8.0);
		addVertex("a",a);

		Hashtable<String, Double> b = new Hashtable<String, Double>();
		b.put("a",4.0);
		b.put("h",11.0);
		b.put("c",8.0);
		addVertex("b",b);
		
		Hashtable<String, Double> c = new Hashtable<String, Double>();
		c.put("b", 8.0);
		c.put("i", 2.0);
		c.put("d", 7.0);
		c.put("f", 4.0);
		addVertex("c",c);
		
		Hashtable<String, Double> d = new Hashtable<String, Double>();
		d.put("c", 7.0);
		d.put("e", 9.0);
		d.put("f", 14.0);
		addVertex("d",d);
		
		Hashtable<String, Double> e = new Hashtable<String, Double>();
		e.put("d",9.0);
		e.put("f",10.0);
		addVertex("e",e);
		
		Hashtable<String, Double> f = new Hashtable<String, Double>();
		f.put("c",4.0);
		f.put("d",14.0);
		f.put("e",10.0);
		f.put("g",2.0);
		addVertex("f",f);
		
		Hashtable<String, Double> g = new Hashtable<String, Double>();
		
		addVertex("g",g);
		
		Hashtable<String, Double> h = new Hashtable<String, Double>();
		
		addVertex("h",h);
		
		Hashtable<String, Double> i = new Hashtable<String, Double>();
		
		addVertex("i",i);
		
		
	}
	
	
}
